<?php

namespace App\Models;

use Dcat\Admin\Traits\HasDateTimeFormatter;

use Dcat\Admin\Traits\ModelTree;
use Illuminate\Database\Eloquent\Model;

/**
 * App\Models\City
 *
 * @property int $id
 * @property string|null $name
 * @property string|null $lat
 * @property string|null $lng
 * @property int|null $parent_id
 * @property int|null $order
 * @method static \Illuminate\Database\Eloquent\Builder|City newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|City newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|City ordered(string $direction = 'asc')
 * @method static \Illuminate\Database\Eloquent\Builder|City query()
 * @method static \Illuminate\Database\Eloquent\Builder|City whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|City whereLat($value)
 * @method static \Illuminate\Database\Eloquent\Builder|City whereLng($value)
 * @method static \Illuminate\Database\Eloquent\Builder|City whereName($value)
 * @method static \Illuminate\Database\Eloquent\Builder|City whereOrder($value)
 * @method static \Illuminate\Database\Eloquent\Builder|City whereParentId($value)
 * @mixin \Eloquent
 * @property string|null $pinyin
 * @property string|null $first
 * @method static \Illuminate\Database\Eloquent\Builder|City whereFirst($value)
 * @method static \Illuminate\Database\Eloquent\Builder|City wherePinyin($value)
 * @property-read \Illuminate\Database\Eloquent\Collection|City[] $children
 * @property-read int|null $children_count
 */
class City extends Model
{

    use HasDateTimeFormatter, ModelTree;

    protected $table = 'city';
    protected $titleColumn = 'name';
    public $timestamps = false;

    public function children()
    {
        return $this->hasMany(City::class, 'parent_id', 'id');
    }
}
